package com.ruoyi.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.system.domain.client.*;
import com.ruoyi.system.mapper.MesClientAllMapper;
import com.ruoyi.system.mapper.MesClientConfigMapper;
import com.ruoyi.system.mapper.MesClientPagesRelationMapper;
import com.ruoyi.system.mapper.MesClientUsagesMapper;
import com.ruoyi.system.service.IMesClientPagesRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;


/**
 * 客户端页面对应关系Service业务层处理
 *
 * @author ruoyi
 * @date 2023-02-20
 */
@Service
public class MesClientPagesRelationServiceImpl extends ServiceImpl<MesClientPagesRelationMapper, MesClientPagesRelation> implements IMesClientPagesRelationService {

    @Autowired
    private MesClientAllMapper mesClientAllMapper;
    @Autowired
    private MesClientConfigMapper mesClientConfigMapper;
    @Autowired
    private MesClientUsagesMapper mesClientUsagesMapper;

    @Override
    public MesClientAllDTO getAllInfo(Integer clientId) {
        MesClientAll mesClientAll = mesClientAllMapper.selectById(clientId);
        MesClientAllDTO mesClientAllDTO = new MesClientAllDTO();
        BeanUtil.copyProperties(mesClientAll,mesClientAllDTO);
        List<MesClientConfig> listConfig = mesClientConfigMapper.selectList(new QueryWrapper<MesClientConfig>().eq("client_id", clientId));
        List<MesClientUsages> listUsages = mesClientUsagesMapper.selectList(new QueryWrapper<MesClientUsages>().eq("client_id", clientId));
        mesClientAllDTO.setListConfig(listConfig);
        mesClientAllDTO.setListUsages(listUsages);
        return mesClientAllDTO;
    }
}
